package com.skydroid.h16

import android.Manifest
import android.content.Context
import android.os.Bundle
import android.view.View
import android.widget.RadioGroup
import androidx.appcompat.app.AppCompatActivity
import androidx.core.app.ActivityCompat
import com.skydroid.h16.R


class MainActivity : AppCompatActivity() {

    private var mContext: Context? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        this.mContext = this
        requestPermissions()
        initView()

    }

    private fun initView(){

        var viewDecode = findViewById(R.id.view_decode) as? RadioGroup
        findViewById<View>(R.id.btn_player_rtsp).setOnClickListener {
            when(viewDecode?.checkedRadioButtonId){
                R.id.btn_soft->{
                    VideoActivity.start(this@MainActivity, 0)
                }
                R.id.btn_hardware->{
                    VideoActivity.start(this@MainActivity, 1)
                }
            }

        }

        findViewById<View>(R.id.btn_sky_uart).setOnClickListener {
            SkyDataActivity.start(this@MainActivity)
        }

        findViewById<View>(R.id.btn_rc_uart).setOnClickListener {
            RCDataActivity.start(this@MainActivity)
        }
       findViewById<View>(R.id.btn_rocker).setOnClickListener {
           RockerActivity.start(this@MainActivity)
        }
        findViewById<View>(R.id.btn_change_mode).setOnClickListener {
            ChangeModeActivity.start(this@MainActivity)
        }


    }

    private fun requestPermissions() {
        ActivityCompat.requestPermissions(
            this, arrayOf(
                Manifest.permission.ACCESS_FINE_LOCATION,
                Manifest.permission.READ_EXTERNAL_STORAGE,
                Manifest.permission.WRITE_EXTERNAL_STORAGE
            ), 0
        )
    }



}
